using System.Web.Mvc;
using Microsoft.Practices.Unity;
using Unity.Mvc4;
using DAL.DBInteractions;
using MvcPortal.IoC;
using BLL.Interfaces;
using DAL.EntityRepository;
using BLL;

namespace GUI
{
  public static class Bootstrapper
  {
    public static IUnityContainer Initialise()
    {
      var container = BuildUnityContainer();

      DependencyResolver.SetResolver(new Unity.Mvc4.UnityDependencyResolver(container));

      return container;
    }

    private static IUnityContainer BuildUnityContainer()
    {
      var container = new UnityContainer();



      // register all your components with the container here
      // it is NOT necessary to register your controllers

      // e.g. container.RegisterType<ITestService, TestService>();    
      RegisterTypes(container);

      return container;
    }

    public static void RegisterTypes(IUnityContainer container)
    {
        container
          .RegisterType<IDBFactory, DBFactory>(new HttpContextLifetimeManager<IDBFactory>())
          .RegisterType<IUnitOfWork, UnitOfWork>(new HttpContextLifetimeManager<IUnitOfWork>())
         
          .RegisterType<IAuteurServices, AuteurServices>(new HttpContextLifetimeManager<IAuteurServices>())
          .RegisterType<IAuteurRepository, AuteurRepository>(new HttpContextLifetimeManager<IAuteurRepository>())

            .RegisterType<IArticlesServices, ArticlesServcices>()
            .RegisterType<IArticleRepository, ArticleRepository>()
                
            .RegisterType<ILogsServices,LogServices>(new HttpContextLifetimeManager<ILogsServices>())
            .RegisterType<ILogRepository, LogsRepository>(new HttpContextLifetimeManager<ILogRepository>())

            .RegisterType<IUserProfileServices, UserProfileServices>(new HttpContextLifetimeManager<IAuteurServices>())
           .RegisterType<IUserProfileRepository, UserProfileRepository>(new HttpContextLifetimeManager<IAuteurServices>());
        

    
    }
  }
}